const app = getApp()
const { formatObjToUrl, RandomColor } = require('../../utils/util')
// pages/records/records.js
Page({

  data: {
    recordOptions: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // 获取考试记录
    this.getRecordOptions()
  },

  // 获取考试记录
  getRecordOptions() {
    app.axios({
      url: `/score/select_score`
    }).then(res => {
      if(res.code === 0) {
        this.setData({
          recordOptions: res.result.map(item => {
            return {
              id: item.id,
              score: item.score,
              bgColor: new RandomColor().color,
              addTime: item.addTime,
              openId: item.openid
            }
          })
        })
      }
    })
  },

})